package com.zbec.mdrs.repository.jpa;



import com.zbec.mdrs.entity.Logs;
import com.zbec.mdrs.vo.LogsVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.Date;

/**
 * Created by fxl on 2015/10/17.
 */
public interface LogsDao extends PagingAndSortingRepository<Logs, Long>, JpaSpecificationExecutor<Logs> {




    @Query("select new com.zbec.mdrs.vo.LogsVo(al.id, al.businessType, al.userName, al.operationType, al.operationTime," +
            " al.operationStatus, al.operationDesc,al.userIp,al.logType)" +
            " from Logs al " +
            " where (al.operationTime between :startDate and :endDate)  " +
            " order by al.operationTime  desc")
    Page<LogsVo> findAllLogs( @Param("startDate")Date startDate,@Param("endDate")Date endDate,Pageable pageable);


}
